#include "Event.h"
#include "Order.h"


Transport::Transport(void) 
{
	preSetting();
}

Transport::Transport( string id , int arrivalTime , int maxLoad , int initLoad , int offLoad )
{
	preSetting();
	init(id,arrivalTime,maxLoad,initLoad,offLoad);
	currentLoad = initLoad;
}

Transport::~Transport(void)
{
}

void Transport::printResult( ostream &out )
{
	out << id << endl;
	out << "\tArrived at " << arrivalTime << endl;
	
	out << "\tMoved into the station at " << enterStationTime;
	if (moveInDelay() > 0)
		out << " (" << moveInDelay() << " delayed)";
	out << endl;

	out << "\tLoading/Unloading done at " << doneTime << endl;
	
	out << "\tLeaved at " << leaveTime;
	if (leaveDelay() > 0)
		out << " (" << leaveDelay() << " delayed)";

	out << endl;

	out << "\tCapacity " << capacity << endl;
	out << "\t" << initLoad << " initially loaded " << endl;
	out << "\t" << unLoaded << " unloaded, " << loaded << " loaded"<< endl;
	

	if (AdditionalLoad() > 0)
		out << "\t" << AdditionalLoad() << " additionally loaded" << endl;
	out << "\t" << currentLoad << " currently loaded" << endl;

	if (isShip() && capacity / 2 > currentLoad)
		out << "\t" <<	capacity / 2 - currentLoad << " unit(s) of cargo less than the minimum load" << endl;
		
}

void Transport::preSetting()
{
	enterStationTime = 0 ;
	doneTime = 0;
	leaveTime = 0;
	unLoaded = 0;
	loaded = 0;
	currentLoad = 0;
	repaired = false;
	bShip = false;
}

void Transport::init( string id , int arrivalTime , int maxLoad , int initLoad , int offLoad )
{
	this->id = id;
	this->arrivalTime = arrivalTime;
	this->capacity = maxLoad;
	this->initLoad = initLoad;
	this->offLoad = offLoad;
}
